import request from '@/utils/request'

/**
 * @description 上传图片
 * */
export function uploadImg(data) {
  return request({
    url: '/base/upload',
    headers: {
      repeatSubmit: false
    },
    method: 'post',
    data
  })
}
/**
 * @description 上传文件
 * */
export function uploadFile(data, onUploadProgress) {
  return request({
    url: '/base/upload-file',
    headers: {
      repeatSubmit: false
    },
    method: 'post',
    data,
    onUploadProgress
  })
}
/**
 * @description 页面公共的下拉数据option
 * @param jointUrl 不同页面不同的api请求
 * */
export function getOption(jointUrl) {
  return request({
    url: `/base/get-${jointUrl}-option`,
    method: 'get'
  })
}
/**
 * @description 页面公共的下拉数据option
 * @param jointUrl 不同页面不同的api请求
 * */
export function getOptions(data) {
  return request({
    url: `/base/get-enums`,
    method: 'post',
    data
  })
}

// 获取分类列表
export function getclassificationList(params) {
  return request({
    url: '/base/backend-classification/get-list',
    method: 'get',
    params
  })
}

// 语言
export function getLanguage(params) {
  return request({
    url: '/base/language/get-list',
    method: 'get',
    params
  })
}

// 员工
export function getTenantOrganization(params) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: '/tenant/organization',
    method: 'get',
    params
  })
}

//品牌
export function getBrand(params) {
  return request({
    url: '/api/goods/get-brand-list',
    method: 'get',
    params
  })
}

// 物流属性
export function getLogistics(params) {
  return request({
    url: '/api/goods/get-logistics-attributes',
    method: 'get',
    params
  })
}

// 币种
export function getCurrency(params) {
  return request({
    url: '/base/currency/get-list',
    method: 'get',
    params
  })
}

// 分类数据
export function getColumns() {
  return request({
    url: '/v1/base/base-back-columns/list',
    method: 'get'
  })
}

// 获取仓库数据
export function getWareData(params) {
  return request({
    baseURL: window.APP_GETEWAY.wms,
    url: `/wms_v1_pc/base/get-ware-data`,
    method: 'get',
    params
  })
}

// 平台站点
export function getPlatform() {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: '/v1/platform/tree',
    method: 'get'
  })
}

// 获取供应商列表
export function getSupplie(data) {
  return request({
    baseURL: window.APP_GETEWAY.pms,
    url: `/v1/base/supplier`,
    method: "post",
    data,
  });
}

// 获取店铺
export function getShop(data) {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: `/v1/shop/drop-list`,
    method: "post",
    data,
  });
}

// 获取店铺
export function tmsOptions(data) {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: `/options`,
    method: "post",
    data,
  });
}

// 导出中心详情
export function getExportConfig(id) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_config/${id}`,
    method: "get",
  });
}

// 新增导出详情
export function exportRord(data) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_record`,
    method: "post",
    data
  });
}

// 新增导出模版
export function exporttpl(data) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_tpl`,
    method: "post",
    data
  });
}

// 字段模板
export function exportTemplateOne(params) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_config/one`,
    method: "get",
    params
  });
}

// 删除模板
export function exportTemplateDelete(id) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_tpl/${id}`,
    method: "delete"
  });
}

// 编辑模板
export function exportTemplateEdit(id,data) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_tpl/${id}`,
    method: "put",
    data
  });
}

// 推送赛盒
export function pushsaihe(data) {
  return request({
    url: `/v1/goods/spu/push-to-sai-he`,
    method: "post",
    data
  });
}

// 拉取赛盒
export function pullsaihe(data) {
  return request({
    url: `/v1/goods/spu/pull-from-sai-he`,
    method: "post",
    data
  });
}



// 同步赛盒日志
export function syncsaiheResult(data) {
  return request({
    url: `/v1/goods/spu/get-push-to-sai-he-result`,
    method: "post",
    data
  });
}

// 获取国家 币种option
export function getCountryCurrency(params) {
  return request({
    url: `/base/country/get-list`,
    method: "GET",
    params
  });
}

// 获取国家option
export function getCountrys() {
  return request({
    url: `/api/goods/get-countrys`,
    method: "GET"
  });
}



// 进口商列表
export function getImporter(data) {
  return request({
    url: '/v1/base/importer/list',
    method: 'POST',
    data
  })
}

// 创建图片下载任务
export function ImgDownloadTask(data) {
  return request({
    url: '/v1/base/img-download-task/create',
    method: 'POST',
    data
  })
}

// 批量翻译  旧版本
// export function translationBatch(data) {
//   return request({
//     baseURL: window.APP_GETEWAY.trans,
//     url: '/translate/batch',
//     method: 'post',
//     headers: {
//       repeatSubmit: false
//     },
//     data,
//     timeout: 30000,
//   })
// }

export function translationBatch(data) {
  return request({
    url: '/v1/base/translator/batch',
    method: 'post',
    headers: {
      repeatSubmit: false
    },
    data,
  })
}

// 翻译单个 旧版本
// export function translation(data) {
//   return request({
//     baseURL: window.APP_GETEWAY.trans,
//     url: '/translate',
//     method: 'post',
//     headers: {
//       repeatSubmit: false
//     },
//     data
//   })
// }

export function translation(data) {
  return request({
    url: '/v1/base/translator/single',
    method: 'post',
    headers: {
      repeatSubmit: false
    },
    data
  })
}

// 图片标签列表
export function getImageTag(data) {
  return request({
    url: '/v1/assignment/images-tag/get-tags-by-uid',
    method: 'POST',
    data
  })
}

// 查询条件列表
export function queryConditionList(data) {
  return request({
    url: '/v1/goods/condition/list',
    method: 'POST',
    data
  })
}

// 保存条件列表
export function conditionSave(data) {
  return request({
    url: '/v1/goods/condition/save',
    method: 'POST',
    data
  })
}

// 删除查询条件
export function conditionDelete(data) {
  return request({
    url: '/v1/goods/condition/delete',
    method: 'POST',
    data
  })
}


// 获取历史采购订单价格
export function getPurchaseProcessHistory(params) {
  return request({
    baseURL: window.APP_GETEWAY.pms,
    url: `v1/purchase/purchase-process/history`,
    method: "get",
    params,
  });
}

/**
 * @description 获取采购字段映射关系
 * */
export function getBaseOptions(params) {
  return request({
    url: `/v1/base/get-option`,
    baseURL: window.APP_GETEWAY.pms,
    method: 'GET',
    params
  })
}

/**
 * @description 导出模版
 * */
export function templateDownload(params) {
  return request({
    url: `/template/download`,
    method: 'GET',
    params
  })
}

/**
 * @description 添加供应商资料
 * */
export function supplierCreate(data) {
  return request({
    url: `/v1/supplier/supplier/create`,
    baseURL: window.APP_GETEWAY.pms,
    method: 'POST',
    data
  })
}

/**
 * @description 获取结算方式
 * */
export function getPeriod(params) {
  return request({
    url: `/v1/supplier/supplier/get-period`,
    baseURL: window.APP_GETEWAY.pms,
    method: 'GET',
    params
  })
}

/**
 * @description 获取银行
 * */
export function getBank(params) {
  return request({
    url: `/v1/supplier/supplier/get-bank`,
    baseURL: window.APP_GETEWAY.pms,
    method: 'GET',
    params
  }).then(res => res.data.map(d => ({ label: d.bank_name, value: d.sb_id })))
}

/**
 * @description 属性权限
 * */
export function getAttributesData(params) {
  return request({
    url: `/attributes-access/index`,
    baseURL: window.APP_GETEWAY.auth,
    method: 'GET',
    params
  })
}

// 查询是否存在待审核的变更单
export function changeOrderExist(data) {
  return request({
    url: '/v1/goods/change-order/exist',
    method: 'post',
    data
  })
}

// 获取历史采购订单价格-new
export function getPurchaseHistory(data) {
  return request({
    baseURL: window.APP_GETEWAY.pms,
    url: `/v1/purchase/purchase-process/history-list`,
    method: "POST",
    data,
  });
}

// 供应商列表
export function getSupplierList(data) {
  return request({
    baseURL: window.APP_GETEWAY.pms,
    url: '/v1/base/supplier',
    method: 'post',
    data
  })
}

// 部门列表
export function getDepartment(data) {
  return request({
    baseURL: window.APP_GETEWAY.auth,
    url: '/department',
    method: 'post',
    data
  })
}

// 组织部门列表
export function getColumnsDepartment(params) {
  return request({
    url: '/v1/base/base-back-columns/department',
    method: 'GET',
    params
  })
}

// 申报要素详情
export function getCustomsDetail(data) {
  return request({
    url: '/v1/base/base-customs/detail',
    method: 'POST',
    data
  })
}

// Lishing链接写入
export function getMinPriceBySku(data) {
  return request({
    baseURL: window.APP_GETEWAY.public,
    url: '/api/public/bypass/inner/getMinPriceBySku',
    method: 'POST',
    data
  })
}

// 检测url是否正常
export function getUrlInfo(data) {
  return request({
    url: `/v1/goods/sku/get-url-info`,
    method: 'POST',
    data
  })
}

// 获取sku 所有供应商
export function getSKUSupplier(data) {
  return request({
    url: '/v1/goods/batch-operation/get-supplier',
    method: 'post',
    data
  })
}

// 渠道管理-列表
export function getChannel(data) {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: `/channel/channel/index`,
    method: 'POST',
    data
  })
}

// 运费试算
export function feeTrialCalcFreight(data) {
  return request({
    baseURL: window.APP_GETEWAY.tms,
    url: '/fee/trial-calc/freight',
    method: 'post',
    data
  })
}

// 图片标签列表
export function getImagesTagList(data) {
  return request({
    url: '/v1/assignment/images-tag/list',
    method: 'POST',
    data
  })
}

// 获取sku备注
export function getSKURemark(data) {
  return request({
    url: '/v1/goods/sku/get-sku-remark',
    method: 'POST',
    data
  })
}


// 获取 sku 详情 列表
export function getSKUDetailList(data) {
  return request({
    url: '/v1/goods/sku/detail-list',
    method: 'POST',
    data
  })
}


// 获取 供应商详情 列表
export function getSupplierDetail(params) {
  return request({
    baseURL: window.APP_GETEWAY.pms,
    url: '/v1/supplier/supplier/detail',
    method: 'GET',
    params
  })
}

// 获取 亚马逊售价列表
export function getAmazonPrice(data) {
  return request({
    baseURL: window.APP_GETEWAY.publish,
    url: '/listing/amazon-price-list',
    method: 'POST',
    data
  })
}

// 获取指定sku供应商报关数据
export function getskuSupplierAll(data) {
  return request({
    url: '/v1/goods/sku/get-supplier-all',
    method: 'POST',
    data
  })
}

// 申报要素项-列表
export function queryDeclareElementList(data) {
  return request({
    url: '/v1/base/base-customs/declare-element-list',
    method: 'POST',
    data
  })
}// 获取币种列表
// export function getCurrencyList(params) {
//   return request({
//     url: '/base/currency/get-list',
//     method: 'GET',
//     params
//   })
// }

